e58fe62230285a4b5b7892ca911770e43db2eee3,server/src/main/java/com/vaadin/ui/ComboBox.java,ComboBox,paintContent,#PaintTarget#,234
Before Change
// Paints the options and create array of selected id keys
int keyIndex = 0;
target.startTag("options");
if (currentPage < 0) {
optionRequest = false;
currentPage = 0;
filterstring = "";
}
boolean nullFilteredOut = isFilteringNeeded();
// null option is needed and not filtered out, even if not on
// current page
boolean nullOptionVisible = needNullSelectOption
&& !nullFilteredOut;
// first try if using container filters is possible
List<?> options = getOptionsWithFilter(nullOptionVisible);
if (null == options) {
// not able to use container filters, perform explicit in-memory
// filtering
options = getFilteredOptions();
filteredSize = options.size();
options = sanitetizeList(options, nullOptionVisible);
}
final boolean paintNullSelection = needNullSelectOption
&& currentPage == 0 && !nullFilteredOut;
if (paintNullSelection) {
target.startTag("so");
target.addAttribute("caption", "");
target.addAttribute("key", "");
paintItemStyle(target, null);
target.endTag("so");
}
final Iterator<?> i = options.iterator();
// Paints the available selection options from data source
while (i.hasNext()) {
final Object id = i.next();
if (!isNullSelectionAllowed() && id != null
&& id.equals(getNullSelectionItemId())
&& !isSelected(id)) {
continue;
}
// Gets the option attribute values
final String key = itemIdMapper.key(id);
final String caption = getItemCaption(id);
final Resource icon = getItemIcon(id);
getCaptionChangeListener().addNotifierForItem(id);
// Paints the option
target.startTag("so");
if (icon != null) {
target.addAttribute("icon", icon);
}
target.addAttribute("caption", caption);
if (id != null && id.equals(getNullSelectionItemId())) {
target.addAttribute("nullselection", true);
}
target.addAttribute("key", key);
if (keyIndex < selectedKeys.length && isSelected(id)) {
// at most one item can be selected at a time
selectedKeys[keyIndex++] = key;
After Change
}
// paint the items
target.startTag("options");
for (ComboBoxItem item : items) {
target.startTag("so");
if (item.icon != null) {
target.addAttribute("icon", item.icon);
}
target.addAttribute("caption", item.caption);
target.addAttribute("key", item.key);
if (item.style != null) {
target.addAttribute("style", item.style);
}